<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<sfa:mainTitle></sfa:mainTitle>
<%@ include file="../../common/meta.jsp"%>
<link rel="stylesheet" href="${path}/statics/themes/default/style.css" />
<script type="text/javascript">

function pwdStreng(password){
						 var flag = false;
						  
						  /** 必须包含数字 */
						  var digit = /\S*[0-9]+\S*/;
						  /** 必须包含英文字符 */
						  var letter = /\S*[a-zA-Z]+\S*/;
						  /** 必须包含特殊字符 */
						  var especialChar = /\S*\W+\S*|\S*[_]+\S*/;
						  if ( digit.test(password)
						    &&  letter.test(password)
						    &&  especialChar.test(password)){
						   flag = true;
						  }
						 
						 return flag;
						}

jQuery.validator.addMethod("loginname", function(value, element) {   
    var tel = /^[a-zA-Z][a-zA-Z0-9_]{4,16}$/;
    return this.optional(element) || (tel.test(value));
}, "");

jQuery.validator.addMethod("checkPassword", function(value, element) {   
    var tel = /[\da-zA-Z=\[\];`',.\/~!@#$%^&*()_+|{}:"<>?]{4,16}/;
    return this.optional(element) || (pwdStreng(value));
}, "");

jQuery.validator.addMethod("phonenumber", function(value, element) { 
    var tel = /^(13[0-9]|15[0|3|6|7|8|9]|18[3|6|7|8|9])\d{8}$/;
    return this.optional(element) || (tel.test(value));
}, "");

$(function() {
 
	$("#clear").click(function(){
		$(".inputbox").val("");
	});
	
	
	
	var updateForm=$("#updateForm").validate( { 
		rules : {
			loginName : {
				required : true,
				rangelength:[5,16],
				loginname:true
			},
			userPassword : {
				required : true,
				rangelength:[7,14],
			},
			userName : {
				required : true
			},
			email : {
				required : true,
				email:true
			},
			contactMobile : {
				phonenumber:true
			}
			
		},
		 messages:{
                loginName:{required:"必填",rangelength:"登录名长度5到16位",loginname:"登录名以字母开头，由字母，数字，下划线组成"},
                userPassword:{required:"必填",rangelength:"长度为7到14位"},
                userName:{required:"必填"},
                email:{required:"必填",email:"非法的邮件地址格式"},
                contactMobile:{required:"必填",phonenumber:"手机号码格式不正确"},
                focusInvalid: false,   
 				onkeyup: false //获得焦点时不验证
 				}
	});
	
	
	
	$("#submit").click(function(){
		if(updateForm.form())
		{
			
		 $("#updateForm").ajaxSubmit(function(result) {
			 
				var msg=result.msg;
				 
				if (result.result==true) {
					
					if(result.flag )
					{
				 	 art.dialog( {
				icon : 'success',
				lock : true,
				resize : false,
				title : "修改成功",
				content : msg,
				ok :function(){
					location.href='${path}/manage/role/index/getAllUsers';
				}
					}); 
					
					}else
					{
						art.dialog( {
				icon : 'error',
				lock : true,
				resize : false,
				title : "修改失败",
				content : msg
				});
					}
					 
				} else {
				
				alert(msg);
				}
		 
			});
			 
			}
			});
 

});
</script>
</head>



<body id="master">

	<sfa:mainHeader></sfa:mainHeader>
	
	
	
	
	
	 <!--右边-->
            <div class="webpart3 contentarea">
                <div class="webpart-head">
                    <div class="webpart-head-item">
                        修改信息<font color="red"><c:out value="${update}"></c:out> </font>
						<div class="tools-btn">
                             
                            &nbsp;&nbsp;<a href="javascript:" onclick="javascript: history.back();"><span>
                                <img src="${path}/statics/images/Redo.gif" style="margin-right: 4px; margin-bottom: -3px;" />返回</span></a></div>
                    </div>
                </div>
                <div class="webpart-main">
                    <div class="webpart-main-item" style="padding: 30px;">
                        <div class="d_formitem">
                        <c:set value="${currentUser}" var="curUser"></c:set>
	<form action="${path }/manage/user/index/update" method="post" id="updateForm">
                         
                            <table cellspacing="0" cellpadding="0" class="formitem">
                                <tr align="left">
                                    <td style="width: 60px;">
                                        用户：
                                    </td>
                                    <td>
                                       ${curUser.userName}(${curUser.loginName})
									 
										<input type="hidden" id="loginName" class="inputbox" name="loginName" value="${ curUser.loginName}"/>
						<input type="hidden" id="saleUsersLoginId" class="inputbox" name="saleUsersLoginId" value="${ curUser.saleUsersLoginId}"/>
						<font color="red">${name }</font>
                                    </td>
                                </tr>
                                 
                                <tr align="left">
                                    <td>
                                        密码：
                                    </td>
                                    <td>
                                        <input type="password" id="userPassword" class="input-txt" name="userPassword" value="${curUser.userPassword}" style="width: 40%"/>
						<font color="red">*</font> 
                                    </td>
                                </tr>
                                 
                                <tr align="left">
                                	<td>
                            	姓名：
                                	</td>
                                	<td>
                                		<input type="text" id="userName" class="input-txt" name="userName" 
                                		value="${curUser.userName}" style="width: 40%" />
                                		
						<font color="red">*</font> 
                                	</td>
                                </tr>
                                <tr align="left">
                                    <td>
                                        电子邮件:
                                    </td>
                                    <td>
                                       <input type="text" id="email" class="input-txt" name="email" value="${curUser.email}" style="width: 40%"/>
						<font color="red">*</font> 
                                    </td>
                                </tr>
                                 <tr align="left">
                                    <td>
                                        手机号码:
                                    </td>
                                    <td>
                                      <input type="text" id="contactMobile" class="input-txt" name="contactMobile" value="${curUser.contactMobile}" style="width: 40%"/>
                                    </td>
                                </tr>
                                
                            </table>
                           
                            <div style="margin: 15px;">
                           <input name="submit" type="button" id="submit" tabindex="5"
								class="linkbtn2" value="提交">
							<input name="clear" type="reset" id="" tabindex="5"
								class="linkbtn2" value="重置">
                                 
                            </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="webpart-foot">
                    <div class="webpart-foot-item">
                    </div>
                </div>
            </div>
	
	<sfa:mainFooter></sfa:mainFooter>

</body>
</html>


